#include "dialog.h"
#include <time.h>
#include <math.h>
#include <QPainter>
#include <QTime>

Dialog::Dialog(QWidget *parent) :
        QDialog(parent)//,
        //  ui(new Ui::Dialog)
{
    //  ui->setupUi(this);
    resize(400,400);
    time = new QLabel (this);
    time->resize(100,10);
    time->move(50,150);
    this->startTimer(1000);
}

Dialog::~Dialog()
{
    // delete ui
}
void Dialog::paintEvent(QPaintEvent *)
{
    int k=60;
    QPainter painter(this);
    painter.drawRect(50,50,100,100);
    QPen pen(Qt::DotLine);
    painter.setPen(pen);

    while(k<=140)
    {   //while(k=50&&k=150)
        {}
        painter.drawLine(k,50,k,150);k=k+10;}
    k=140;
    while(k>=60)
    {painter.drawLine(50,k,150,k);k=k-10;}
    int a[10];
    //while(1)
    k=50;
     b[0]=0;
    int i=1;

    //srand((unsigned)time(NULL));
    pen.setColor(QColor(0,0,225));
    pen.setStyle(Qt::SolidLine);
    painter.setPen(pen);

    {

        for(i=1;i<=10;i++)
        {

            painter.drawLine(k,150-b[i-1],k+10,150-b[i]);
            k=k+10;
        }


    }
}
void Dialog::timerEvent(QTimerEvent *)
{
    time->setText(QTime::currentTime().toString());
    // void Dialog::timerEvent(QTimerEvent *);
    int m=1;
    for(m=1;m<=10;m++)
    {
        b[m]=rand()%100;

    }
    this->repaint();
}



